# coding=utf-8
"""
author:董新强
createdate: 2024/2/26 14:48
description: 
"""
import re
from os import walk
from os.path import join

root = r'C:\projects\script-machinedemo\luaext\Sm'

flist = []

for  root,sub,files in walk(root):
    for f in files:
        if not f.endswith('.cpp') and not f.endswith('.h'):
            continue
        flist.append(join(root,f))

regex_comment = re.compile(r"//.*")
for f in flist:
    newcontents=[]
    content = open(f ,'r').read()
    for line in content.split('\n'):
        line = regex_comment.sub('',line)+'\n'
        newcontents.append(line)
    # newcontents = '\n'.join(newcontents)
    with open(f,'w') as w:
        w.writelines(newcontents)
print("处理完成")